import React from 'react'
import { useSelector, useDispatch } from 'react-redux'
import { push, update } from './redux/actions'

export default function List() {
  const list = useSelector((state) => {
    return state.ls.list
  })
  const dispatch = useDispatch()
  return (
    <>
      <ul>
        {list.map((item, index) => {
          return (
            <li key={index}>
              <h1>{item.name}</h1>
              <p>{item.info}</p>
            </li>
          )
        })}
      </ul>
      <button
        onClick={() => {
          dispatch(
            push({
              name: 'zt',
              info: 'lsp',
            })
          )
        }}
      >
        添加
      </button>
      <button
        onClick={() => {
          dispatch(update())
        }}
      >
        修改
      </button>
    </>
  )
}
